let vue = new Vue({
    el :'#login',
    delimiters: ['${','}'],
    data: {

        // v-model
        username: '',
        password: '',

        // v-message
        error_username_msg: '用户名格式错误',
        error_password_msg: '密码格式错误',

        // v-show
        error_username: false,
        error_password: false,
        // QQ相关变量
        qq_url: '',
    },
    mounted(){
        // 页面元素加载完成后自动调用执行当前函数
        this.get_qq_url();
    },

    methods:{
        check_username: function () {
            let reg = /^[a-zA-Z]\w{5,9}$/;
            let reg2 = /^1[3-9]\d{9}$/
            if(reg.test(this.username)){
                this.error_username = false;
            }else if(reg2.test(this.username)){
                this.error_username = false;
            } else{
                this.error_username = true;
            }
        },
        check_password: function () {
            let reg = /^\w{6,18}$/;
            if(!reg.test(this.password)){
                this.error_password = true;
            }else{
                this.error_password = false;
            }
        },
        get_qq_url(){
             // 获取QQ登录扫码函数
            axios.get('/qq/login/',{
                responseType: 'json'
            }).then(response=>{
                if(response.data.code=='200'){
                    this.qq_url = response.data.login_url;
                }
            }).catch(error=>{
                console.log(error.response);
            })
        },

    },
})